package com.tt.aidltryer.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.tt.aidltryer.serviceinterface.IReplyer.Stub;

public class ReplyerService extends Service {

    private Stub replyStub = new Stub() {

        private String mQustion;

        @Override
        public void qustion(String qustion) throws RemoteException {
            mQustion = qustion;
        }

        @Override
        public String answer() throws RemoteException {
            if ("h r u?".equals(mQustion)) {
                return "i am fine,and u?";
            }
            return "all right , nothing here.";
        }
    };

    @Override
    public IBinder onBind(Intent intent) {
        Log.i("kyson", "服务端已经绑定...");
        return replyStub;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("kyson", "服务端已经解绑，等待下一次绑定...");
        return true;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i("kyson", "服务端正在运行...");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("kyson", "服务端已经销毁...");
    }

}
